/**
 * @ClassName DosageConcentrationServiceImpl
 * @Description TODO
 * @Author 沉默小吴
 * @Date 2024/12/23 15:31
 */
package com.tledu.operate.count.service.impl;

import com.tledu.operate.count.entity.CostInfo;
import com.tledu.operate.count.entity.DosageConcentration;
import com.tledu.operate.count.entity.vo.DosageConcentrationJSON;
import com.tledu.operate.count.mapper.DosageConcentrationMapper;
import com.tledu.operate.count.service.IDosageConcentrationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

@Service
public class DosageConcentrationServiceImpl implements IDosageConcentrationService {
    @Autowired
    private DosageConcentrationMapper dosageConcentrationMapper;
    @Override
    public Map<String,Object[]> getDosageConcentration(Long departmentId, String startDate, String endDate, String chemicalAgentId) {
        List<DosageConcentration> dosageConcentration = dosageConcentrationMapper.getDosageConcentration(departmentId, startDate, endDate, chemicalAgentId);
        Map<String, Object[]> response = new HashMap<>();
        response.put("dataAxis", dosageConcentration.stream().map(DosageConcentration::getRecordTime).toArray());
        response.put("costData", dosageConcentration.stream().map(DosageConcentration::getCost).toArray());
        response.put("concentrationData", dosageConcentration.stream().map(DosageConcentration::getDosage).toArray());
//        response.put("yMax", dosageConcentration.stream().map(DosageConcentration::getYMax).findFirst().orElse(0.0));
//        response.put("costInfo", dosageConcentration.stream().map(DosageConcentration::getCostInfo).findFirst().orElse(new CostInfo()));
        return response;
    }
}